package cn.linweijian.kafka.comsumerdemo.controller;

import cn.linweijian.kafka.comsumerdemo.common.Result;
import cn.linweijian.kafka.comsumerdemo.vo.Article;
import cn.linweijian.kafka.comsumerdemo.vo.ReponseResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Description: kafkademo
 * <p>
 * Created by linweijian on 2018/5/31 16:02
 */
@Controller
public class IndexController {
    @RequestMapping("/")
    public String index() {
        return "index";
    }

    @RequestMapping("/list")
    @ResponseBody
    public ReponseResult list() {
        ReponseResult r = new ReponseResult();
        r.setCode("0");
        List<Article> list = Result.getList();
        r.setData(list);
        int size = 0;
        if (list!=null&&list.size() > 0) {
            size = list.size();
        }
        r.setMsg("success");
        r.setCount(size);
        return r;

    }
}
